#!/usr/bin/env ruby

$LOAD_PATH << "../lib"

require "starruby"
require "starframe"
include StarRuby

class MainScene < StarFrame::Scene
  def init
    # @fps = 30 # 処理レート
    # @frame_skip = false # フレームスキップするかどうか
    
    @font = Font.new("fonts/ORANGEKI", 24)
    @white = Color.new(255, 255, 255)
    
    @counter = 0
  end
  
  def update
    exit_scene if Input.keys(:keyboard).include?(:escape)
    @counter += 1
    
    # sleep 0.2 # 処理が重い！ # フレームスキップがオンだと固まる
  end
  
  def render
    i = -1
    @screen.render_text("FPS: #{@game.fps}",                8, 8 + 32 * (i += 1), @font, @white)
    @screen.render_text("Real FPS: %0.6f" % @game.real_fps, 8, 8 + 32 * (i += 1), @font, @white)
    @screen.render_text("Frames: #{@counter}",              8, 8 + 32 * (i += 1), @font, @white)
    @screen.render_text("Ticks: #{Game.ticks}",             8, 8 + 32 * (i += 1), @font, @white)
    # sleep 0.2 # 描画が重い！
  end
end

StarFrame.start :width => 320, :height => 240,
                :title => "Timer (with StarFrame::Scene)", :fullscreen => false
